package com.slz3.business.module.socialManagement.socArticle.service;

import com.slz3.business.frame.module.Repositorys;
import com.slz3.business.module.socialManagement.socArticle.domain.SocArticle;
import com.slz3.business.module.socialManagement.socArticle.domain.SocArticleFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class SocArticleTransactionalServiceImpl implements SocArticleTransactionalService {

    @Override
    public SocArticle modify(SocArticle socArticleNew) {
        Repositorys.socArticle.test();
        Repositorys.socArticle.save(SocArticleFactory.initBaseFields());
        System.err.println(1/0);
        socArticleNew.setLastModifyTime(LocalDateTime.now());
        return Repositorys.socArticle.saveAndFlush(socArticleNew);
    }

    @Override
    public List<SocArticle> batchModify(List<SocArticle> socArticleList) {
        return Repositorys.socArticle.saveAll(socArticleList);
    }
}
